/* jshint esversion: 8 */
import * as types from '@/store/types.js';
import { getNotification } from '@/api/notification';

export default {
  state: {
    Notification: {},
  },
  
  getters: {
    /*** 返回 通知消息 数据 ***/
    [types.GNotification](state) {
      return state.Notification;
    },
  },

  actions: {
    /*** 获取 通知消息 数据 ***/
    [types.ANotification](ctx, query) {
      return new Promise((resolve, reject) => {
        getNotification(query).then((data) => {
          ctx.commit(types.MNotification, data);
          resolve();
        }).catch(error => {
          ctx.commit(types.MNotification, {});
          reject(error);
        });
      });
    },
  },

  mutations: {
    /*** 填充 通知消息 数据 ***/
    [types.MNotification](state, access) {
      state.Notification = access;
    },
  }
};